<%@ page import="JoinDAO.JoinVO"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<meta charset="utf-8">
<title>Test</title>
	<meta http-equiv="Content-Script-Type" content="text/javascript" />
	<meta http-equiv="Content-Style-Type" content="text/css" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<link href="css/style_main.css" rel="stylesheet" type="text/css" />
	<script src="js/common_group.js" language="Javascript" type="text/javascript"></script>

	<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
	<script src="js/main.js"></script>
	<script type="text/javascript">
	<% 
	String id = null;
	String name = null;
	
	if( session.getAttribute("MemberInfo") != null){
		JoinVO jvo =  (JoinVO)session.getAttribute("MemberInfo");
		id = jvo.getId();
		name = jvo.getName();
	}
	%>
	$(document).ready(function(){
		var id = "<%=id%>";
		//alert(id);
		if(id!="null"){
			$('img[name=1]').attr({'src':'images/logout.gif'});
			$('img[name=2]').attr({'src':'images/info.gif'});
		}
		
	});
	
	<% 
		int re =0;
		if((String)session.getAttribute("re")!=null){
		re = Integer.parseInt((String)session.getAttribute("re"));
		System.out.println(re);
	
	%>
	if(<%= re==1 %>){
		alert("아이디가 없습니다");
		<% session.removeAttribute("re"); %>
	}
	else if (<%=re==2%>){
		alert("비밀번호가 틀렸습니다");
		<% session.removeAttribute("re"); %>
	}else if (<%=re==3%>){
		alert("로그인 되었습니다");
		re=0;
	}
	<%
	}
	%>
	
	$(document).ready(function(){
		$('#sub').click(function(){
			$.ajax({
				url:"logIn_insert_action.log",
				type:"post",
				data:"id="+$('input[name=id]').val()+"&"+"password="+$('input[name=password]').val(),
				dataType:"xml",
				success:function(data){
					console.log(data);
					var count = $(data).find("count").text();
					if(count=="1"){
						//alert("로그인이 완료되었습니다.");
						location.assign("main.jsp");
						location.assign("#");
					}else{
						alert("아이디와 비밀번호를 확인해주세요");
					}		
				},
				error:function(err){
					alert(err + "에러입니다");
				}	
			}); // end of Ajax
			
		}); // end of click
		
	});
	
	
	</script>
</head>
<body class="main">

<!--skip S-->
<ul class="skip">
	<li><a href="#nav">주메뉴 바로가기</a></li>
	<li><a href="#quickArea">메인내용 바로가기</a></li>
	<li><a href="#slide_top">퀵메뉴 바로가기</a></li>
	<li><a href="#footer">하단 바로가기</a></li>
</ul>
<!--skip E-->

<!-- siteAlign S -->
<div id="siteAlign">

	<!-- header S -->
	<div id="header">

			<h1><a href="main.jsp"><img src="images/common/logo1.gif" alt="버라이어티 쿠킹 클래스 Amy Cooking" /></a></h1>

	</div>

	<hr />

	<!-- navi S -->
	<div id="nav">

		<h2 class="desc">사이트 메뉴</h2>

		<ul>
			<li><a href="#"><img src="images/common/navi_ingi.gif" alt="인기 티셔츠" /></a></li>
			<li><a href="test.uload?product_classify=brand"><img src="images/common/navi_brand.gif" alt="브랜드 티셔츠" /></a></li>
			<li><a href="test.uload?product_classify=suip"><img src="images/common/navi_suip.gif" alt="수입 브랜드" /></a></li>
			<li><a href="test.uload?product_classify=chart"><img src="images/common/navi_cha.gif" alt="캐릭터 티셔츠" /></a></li>
			<li><a href="#"><img src="images/common/my.gif" alt="마이 페이지" /></a></li>
		</ul>


		<div class="topsearch">
		
		<%
			if(id == null)
			{
		%>
		<fieldset>
			<input type="image" src="images/common/btn_baguni.gif" class="submit" alt="장바구니" />
			<input type="image" src="images/common/btn_center.gif" class="submit" alt="고객센터" />
		</fieldset>
		<% }else{ %>
		<fieldset>
		    <a href="logout.jsp"><img src="images/common/btn_logout2.gif" class="submit" alt="로그아웃" /></a>
			<input type="image" src="images/common/btn_baguni.gif" class="submit" alt="장바구니" />
			<input type="image" src="images/common/btn_center.gif" class="submit" alt="고객센터" />
		</fieldset>
		<% } %>
		

		<!--
		<!--로그인 후 S --
			안녕하세요! <b class="name">오나경</b> 님 [콩 보유개수 : <b class="soy">1209</b>개]&nbsp;
			<a href="#"><img src="images/common/btn_logout.gif" alt="로그아웃" /></a>			
			<a href="#"><img src="images/common/btn_modify.gif" alt="정보수정" /></a>
		<!--로그인후 E --

		-->
		
		</div>


	</div>


</body>
</html>